using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using emp.Model;
using emp.IDAL;
using System.Collections;
namespace emp.SqlServerDAL
{
   public  class TaskBasic : ITaskBasic
    {
       public IList getTask_Basic()
       {
           string SQL_SELECT_USER_LIST = "select tbi_id,tbi_value from TASK_BASIC_INFO order by tbi_id";
           IList questlist = new ArrayList();
           SqlParameter[] parm = new SqlParameter[] { };
           //Execute a query to read the products
           using (SqlDataReader rdr = SQLHelper.ExecuteReader(SQLHelper.CONN_STRING_NON_DTC, CommandType.Text, SQL_SELECT_USER_LIST, parm))
           {
               while (rdr.Read())
               {
                   TaskBasicInfo tb =
                       new TaskBasicInfo(rdr.GetInt32(0),rdr.GetString(1));
                   questlist.Add(tb);
               }
           }
           return questlist;
       }

       public int getTBI_ITEM_ID(int tbi_id)
       {
           string strSql = "select TBI_ITEM_ID from TASK_BASIC_INFO where TBI_ID="+tbi_id+"";

           int retValue=0;
           SqlConnection Conn = new SqlConnection(ConfigurationSettings.AppSettings["SQLConnString1"]);
           SqlCommand Comm = new SqlCommand(strSql, Conn);
           try
           {
               Conn.Open();
               SqlDataReader reader = Comm.ExecuteReader();
               while (reader.Read())
               {
                   retValue = reader.GetInt32(0);
               }
               //reader.Close(); 
           }
           catch (SqlException ex)
           {
               throw;
           }
           finally
           {
               Conn.Close();
           }
           return retValue;
       }

    }
}
